#include "../apue.h"

static void charatatime(char * ch);

int main(void)
{
    pid_t pid;

    TELL_WAIT();

    if ((pid = fork()) < 0)
        err_sys("fork error");
    else if (pid == 0)
    {
        WAIT_PARENT();
        charatatime("output from child\n");
        //TELL_PARENT(getppid());
    } else {
        //WAIT_CHILD();
        charatatime("output from parent\n");
        TELL_CHILD(pid);
    }

    exit(0);
}

static void charatatime(char * ch)
{
    char * ptr;
    int c;
    setbuf(stdout, NULL);

    for (ptr = ch; (c = *ptr++) != 0;)
        putc(c, stdout);
}
